package com.ziyu.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ziyu.api.system.entity.SysUser;
import com.ziyu.common.core.utils.StringUtils;
import com.ziyu.system.mapper.SysUserMapper;
import com.ziyu.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用户 业务层处理
 *
 * @author cyj
 */
@Service
public class SysUserServiceImpl implements ISysUserService {

    @Autowired
    private SysUserMapper userMapper;

    /**
     * 根据条件分页查询用户列表
     *
     * @param user 用户信息
     * @return 用户信息集合信息
     */
    @Override
    public List<SysUser> selectUserList(SysUser user) {
        QueryWrapper<SysUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.like(!StringUtils.isEmpty(user.getUserName()), "user_name", user.getUserName());
//        queryWrapper.eq("status", user.getStatus());
//        queryWrapper.like("phonenumber", user.getPhonenumber());
//        queryWrapper.ge("create_time", user.getParams().get("beginTime"));
//        queryWrapper.le("create_time", user.getParams().get("endTime"));
//        queryWrapper.eq("dept_id", user.getDeptId());
        return userMapper.selectList(queryWrapper);
    }

    @Override
    public SysUser selectUserByUserName(String userName) {
        QueryWrapper<SysUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_name", userName);
        return userMapper.selectOne(queryWrapper);
    }

    @Override
    public SysUser selectUserById(Long userId) {
        return userMapper.selectById(userId);
    }

}
